package ooExercise.ooday04;

public class AnimalTest {
    public static void main(String[] args) {
        Animal[] animals = new Animal[3];
        animals[0] = new Dog("吞吞", 2, "白", "骨头");
        animals[1] = new Chick("阿芬", 3, "黄", "玉米");
        animals[2] = new Fish("小七", 4, "黑", "虾米");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog) {
                Dog dog = (Dog) (animals[i]);
                dog.lookHome();
            }
            if (animals[i] instanceof Chick) {
                Chick chick = (Chick) (animals[i]);
            }
            if (animals[i] instanceof Swim) {
                Swim swim = (Swim) (animals[i]);
                swim.swim();
            }
        }
        System.out.println("---------------------------------");
        Master master = new Master();
        Dog dog = new Dog("阿华", 1, "白", "骨头");
        Chick chick = new Chick("阿新", 3, "黄", "猫条");
        Fish fish = new Fish("阿芬", 2, "黑", "虾米");
        master.feed(dog);
        System.out.println();
        master.feed(chick);
        System.out.println();
        master.feed(fish);
        System.out.println();
        Master master1 = new Master();
        Animal[] animals1 = new Animal[3];
        animals1[0] = new Dog("吞吞", 2, "白", "骨头");
        animals1[1] = new Chick("阿芬", 3, "黄", "玉米");
        animals1[2] = new Fish("小七", 4, "黑", "虾米");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            master.feed(animals[i]);
        }


    }
}
